package com.maxatime.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maxatime.dao.ExamPlaceMapper;
import com.maxatime.pojo.entity.ExamPlace;
import com.maxatime.service.ExamplaceService;
import com.maxatime.util.SerialNumberUtil;

@Service
public class ExamplaceServiceImpl implements ExamplaceService{

	@Autowired
	ExamPlaceMapper examPlaceMapper;
	
	
	@Override
	public int deleteByPrimaryKey(Integer pkId) {
		// TODO Auto-generated method stub
		return examPlaceMapper.deleteByPrimaryKey(pkId);
	}

	@Override
	public int insert(ExamPlace record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(ExamPlace record) {
		// TODO Auto-generated method stub
		ExamPlace examPlace = new ExamPlace();
		BeanUtils.copyProperties(record, examPlace);
		Date d = new Date();
		examPlace.setCreateDate(d);
		examPlace.setUpdateDate(d);
		examPlace.setDeleteFlag("0");
		String examPlaceId = String.valueOf(SerialNumberUtil.getRandomNum());
		examPlace.setExamPlaceId(examPlaceId);
		examPlaceMapper.insertSelective(examPlace);
		return 0;
	}

	@Override
	public ExamPlace selectByPrimaryKey(Integer pkId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(ExamPlace record) {
		// TODO Auto-generated method stub
		ExamPlace examPlace = new ExamPlace();
		BeanUtils.copyProperties(record, examPlace);
		Date d = new Date();
		examPlace.setUpdateDate(d);
		examPlaceMapper.updateByPrimaryKeySelective(examPlace);
		return 0;
	}

	@Override
	public int updateByPrimaryKey(ExamPlace record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object> list(ExamPlace ExamPlace) {
		// TODO Auto-generated method stub
		PageHelper.startPage(ExamPlace.getPageNum(), ExamPlace.getPageSize());
		List<ExamPlace> examPlace = examPlaceMapper.list(ExamPlace);
		PageInfo<ExamPlace> pageInfo = new PageInfo<ExamPlace>(examPlace);
		Map<String, Object> m = new HashMap<String, Object>();
		m.put("examPlace", examPlace);
		m.put("pageInfo", pageInfo);
		return m;
	}

	@Override
	public ExamPlace find(int pkId) {
		// TODO Auto-generated method stub
		return examPlaceMapper.find(pkId);
	}

}